package com.example.blog.mapper;

import com.example.blog.model.UserInfo;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Select;

@Mapper
public interface UserInfoMapper {

    //插入用户名和密码
    @Options(useGeneratedKeys = true, keyProperty = "id")
    @Insert("insert into user(user_name, password) values (#{userName}, #{password})")
    Integer insertUser(UserInfo user);

    //根据用户名查询用户信息
    @Select("select * from user where user_name = #{userName} and delete_flag != 1")
    UserInfo selectByUserName(String userName);

    //根据id查询用户信息
    @Select("select * from user where id = #{id} and delete_flag != 1")
    UserInfo selectById(Integer id);
}
